using System;

namespace codebase.UI
{
    public abstract class FrameBase : Control
    {
        public int BorderColor = ColorExtensions.BLACK16;

        public string Text = "";

        public void Init(int x, int y,int w, int h, Window parent)
        {
            Parent = parent;

            Left = x * Parent.Parent.screen.CharacterWidth;
            Top = y * Parent.Parent.screen.CharacterHeight;
            Width = w * Parent.Parent.screen.CharacterWidth;
            Height = h * Parent.Parent.screen.CharacterHeight;
        }

        protected override void DrawAll()
        {
            Draw();
        }

        protected override void Draw()
        {
            if (Text != "")
            {
                Parent.Parent.screen.DrawFilledRectangle(Left + Parent.Left , Top + Parent.Top , Left + Width + Parent.Left , Top + Parent.Parent.screen.CharacterHeight + Parent.Top , BorderColor);

                Parent.Parent.screen.DrawText(Text, Left + Parent.Left, Top + Parent.Top, true,0, BackgroundColor);

                Parent.Parent.screen.DrawFilledRectangle(Left + Parent.Left, Top + Parent.Top + Parent.Parent.screen.CharacterHeight , Left + Width + Parent.Left , Top + Height + Parent.Top , BackgroundColor);
                Parent.Parent.screen.DrawRectangle(Left + Parent.Left , Top + Parent.Top + Parent.Parent.screen.CharacterHeight , Left + Width + Parent.Left , Top + Height + Parent.Top , BorderColor);
            }
            else
            {
                Parent.Parent.screen.DrawFilledRectangle(Left + Parent.Left , Top + Parent.Top , Left + Width + Parent.Left , Top + Height + Parent.Top , BackgroundColor);
                Parent.Parent.screen.DrawRectangle(Left + Parent.Left , Top + Parent.Top , Left + Width + Parent.Left , Top + Height + Parent.Top , BorderColor);
            }
        }
    }
}
